<?php

namespace app\controller;

class File
{
    public function upload()
    {
        $file = request()->file('file');
        $savename = \think\facade\Filesystem::disk('public')->putFile('files', $file);
        $savename = str_replace("\\", "/", $savename);
        return json([
            'code' => 20000,
            'msg' => 'ok',
            'data' => [
                'url' => env('app_url') . "/storage/" . $savename
            ]
        ]);
    }



    public function uploadPdf()
    {


        $file = request()->file('file');
        $savename = \think\facade\Filesystem::disk('public')->putFile('files', $file);
        $savename = str_replace("\\", "/", $savename);
        return json([
            'code' => 20000,
            'msg' => 'ok',
            'data' => [
                'cover' => env('app_url') . "/static/images/pdf.png",
                'url' => env('app_url') . "/storage/" . $savename
            ]
        ]);
    }
}
